﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApp_Session
{
    public partial class _default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            /*
             *   关于Session过期，问：时间的起算点，从何时开始计算30分钟？ 从不操作服务器端的资源开始计时。 
             *   关于Session销毁，问：浏览器关闭，session就销毁了吗？ 不对
             * 
             */

            Response.Write("SessionID:" + Session.SessionID + "<br/>");
            Response.Write("--------------------------------------------------------------<br/>");


            for (int i = 0; i < Session.Keys.Count; i++)
            {
                string key = Session.Keys[i];
                string val = Session[key].ToString();
                Response.Write(key + "&nbsp;&nbsp;" + val + "<br/>");

            }

            Response.Write("--------------------------------------------------------------<br/>");
            for (int j = 0; j < Request.Cookies.Count; j++)
            {
                HttpCookie cookie = Request.Cookies[j];
                Response.Write(cookie.Name + "&nbsp;&nbsp;" + cookie.Value + "&nbsp;&nbsp;" + cookie.Expires.ToString("yyyy-MM-dd HH:mm:ss.fff") + "<br/>");
            }
        }

        protected void btnAbort_Click(object sender, EventArgs e)
        {
            Session.Clear();
        }
    }
}